﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using TMDT_Nhom1A.Service;
using TMDT_Nhom1A.DAO;
using TMDT_Nhom1A.DTO;
using System.Collections.Generic;

namespace TMDT_Nhom1A.BUS
{
    public class CouponWebservice_BUS
    {
        public static string Authenticate(string username, string password)
        {
            return CouponWebservice_DAO.Authenticate(username, password);
        }

        public static bool CheckSid(string sid)
        {
            return CouponWebservice_DAO.CheckSid(sid);
        }

        public static Coupon[] FindAllCoupons(string path)
        {
            return CouponWebservice_DAO.FindAllCoupons(path);
        }

        public static Coupon[] FindCoupons(string productName,
                           DateTime startDate, DateTime endDate,
                           int minPrice, int maxPrice, string path)
        {
            // kiem tra du lieu
            if (productName != "")
            {
                productName = productName.Trim();
            }


            short flag = 0;
            if (productName == null && productName == "")
            {
                flag = 1;
            }
            else
                flag = 2;

            return CouponWebservice_DAO.FindCoupons(productName, startDate, endDate, minPrice, maxPrice, flag, path);
        }

        //public static Coupon[] FindCoupons(string[] parameterNames, string[] parameterValues)
        //{
        //    return CouponWebservice_DAO.FindCoupons(parameterNames, parameterValues);
        //}

        public static Coupon FindCouponInfo(string couponId, string path)
        {
            return CouponWebservice_DAO.FindCouponInfo(couponId, path);
        }

        public static bool RegisterCoupon(string sid, string couponId)
        {
            return CouponWebservice_DAO.RegisterCoupon(sid, couponId);
        }

        public static string OrderCoupon(string sid, string couponID, int count)
        {
            return CouponWebservice_DAO.OrderCoupon(sid, couponID, count);
        }

        public static bool ValidateOrder(string sid, string validationCode)
        {
            return CouponWebservice_DAO.ValidateOrder(sid, validationCode);

        }

       

        public static bool CancelOrder(string validationCode)
        {
            return CouponWebservice_DAO.CancelOrder(validationCode);
        }

        public static TMDT_Nhom1A.TransportWS.TransportCompany[] GetTranports()
        {
            return CouponWebservice_DAO.GetTranports();
        }

        public static bool CallWebserviceFromMuaChung(string validationCode)
        {
            return CouponWebservice_DAO.CallWebserviceFromMuaChung(validationCode);
        }

        public static string ConfirmOrder(string transCompanyId, string transTypeId, string validationCode, ContactInfo contact)
        {
            return CouponWebservice_DAO.ConfirmOrder(transCompanyId, transTypeId, validationCode, contact);
        }

        //lien quan toi ngan hang
        public static List<BANK_WEBSERVICE> getAllBank()
        {
            return CouponWebservice_DAO.getAllBank();
        }

        public static string getBankUrl(string bankID)
        {
            return CouponWebservice_DAO.getBankUrl(bankID);
        }

        public static void getBankAccountWebservice(ref string username,ref string password,string bankID)
        {
            CouponWebservice_DAO.getBankAccountWebservice(ref username, ref password,bankID);
        }

        //lay so the thanh toan cua doanh nghiep biz ung voi ngan hang do
        public static string getSoTheThanhToanDNBiz(string bankID)
        {
            return CouponWebservice_DAO.getSoTheThanhToanDNBiz(bankID);
        }

        public static string Transport(string transCompanyId, string transTypeId, string validationCode, ContactInfo contact,ref int quantity)
        {
            return CouponWebservice_DAO.Transport(transCompanyId, transTypeId, validationCode, contact,ref quantity);
        }

        public static bool UpdateStatusOrderAfterCheckout(string orderB2BID,string bankId ,int transportCompanyId,string transportType,string url)
        {
            return CouponWebservice_DAO.UpdateStatusOrderAfterCheckout(orderB2BID,bankId,transportCompanyId,transportType,url);
        }

    }
}
